/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PreferencesForm.java
 *
 * Created on 15.06.2011, 17:59:48
 */

package testmanager;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Window;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.japura.gui.CollapsibleRootPanel;
import org.japura.gui.Decorator.Direction;
import org.japura.gui.Gradient;

/**
 *
 * @author Alex
 */
public class PreferencesForm extends javax.swing.JFrame {
    private static short instanceCount = 0;

    /** Creates new form PreferencesForm */
    public PreferencesForm() {
        initComponents();
        userInitComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Preferences");
        setAlwaysOnTop(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowDeactivated(java.awt.event.WindowEvent evt) {
                formWindowDeactivated(evt);
            }
        });

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Save (64x64).png"))); // NOI18N
        jButton1.setText("Save");
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jButton6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/PowerOff (64x64).png"))); // NOI18N
        jButton6.setText("Close");
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        fileMenu.setText("File");

        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setText("Save As ...");
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText("Edit");

        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setText("Help");

        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 291, Short.MAX_VALUE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                    .addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
                .addContainerGap(458, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        this.dispose();
}//GEN-LAST:event_jButton6ActionPerformed

    private void formWindowDeactivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeactivated
        setFormTransparancy(0.65f);
    }//GEN-LAST:event_formWindowDeactivated

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        setFormTransparancy(1.0f);
    }//GEN-LAST:event_formWindowActivated

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if(instanceCount==0){
                    PreferencesForm frame = new PreferencesForm();
                    frame.setVisible(true);
                   // frame.pack();
                    instanceCount=1;
                }
                else{
                    
                }
            }
        });
    }

    @Override
    public void dispose() {
        super.dispose();
        instanceCount=0;
    }

     private void userInitComponents(){
        collapsibleRootPanel1 = new org.japura.gui.CollapsibleRootPanel(CollapsibleRootPanel.Mode.FILL);
        collapsibleRootPanel1.setBackground(getContentPane().getBackground());
        collapsibleRootPanel1.setBounds(0, 120, getContentPane().getWidth(), getContentPane().getHeight()-130);
//      ------------------------------------------------------------------------
        collapsiblePanel1 = new org.japura.gui.CollapsiblePanel();
        collapsiblePanel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Preferences (32x32).png")));
        collapsiblePanel1.setTitle("General");

//      ------------------------------------------------------------------------
        collapsiblePanel2 = new org.japura.gui.CollapsiblePanel();
        collapsiblePanel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/lock (32x32).png")));
        collapsiblePanel2.setTitle("CVS Preferences");

        jPanel1 = new javax.swing.JPanel();
        jCVSUserNameLabel = new javax.swing.JLabel();
        jCVSPasswordLabel = new javax.swing.JLabel();
        jCVSUserNameField = new javax.swing.JTextField();
        jCVSPasswordField = new javax.swing.JPasswordField();
        jCVSRemmemberPasswordCheckBox = new javax.swing.JCheckBox();

        jCVSUserNameLabel.setText("User Name:");
        jCVSPasswordLabel.setText("Password:");
        jCVSRemmemberPasswordCheckBox.setText("Remmember password");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jCVSUserNameLabel)
                        .addGap(4, 4, 4)
                        .addComponent(jCVSUserNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jCVSPasswordLabel)
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCVSRemmemberPasswordCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
                            .addComponent(jCVSPasswordField, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))))
                .addGap(191, 191, 191))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCVSUserNameLabel)
                    .addComponent(jCVSUserNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCVSPasswordLabel)
                    .addComponent(jCVSPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCVSRemmemberPasswordCheckBox)
                .addContainerGap(137, Short.MAX_VALUE))
        );

        pack();
        
        collapsiblePanel2.add(jPanel1);
//      ------------------------------------------------------------------------
        collapsiblePanel3 = new org.japura.gui.CollapsiblePanel();
        collapsiblePanel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/magnifying glass (32x32).png")));
        collapsiblePanel3.setTitle("Testing");
        
        jPanel2 = new javax.swing.JPanel();
        jNumberOfThreadsLabel = new javax.swing.JLabel();
        jNumberOfThreadsSpinner = new javax.swing.JSpinner();
        jTestListenersLabel = new javax.swing.JLabel();
        jAddTestListenerButton = new javax.swing.JButton();
        jRemoveTestListenerButton = new javax.swing.JButton();
        jReportersLabel = new javax.swing.JLabel();
        jAddReporterButton = new javax.swing.JButton();
        jRemoveReporterButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        testListenersCheckList = new org.japura.gui.CheckList();
        jScrollPane2 = new javax.swing.JScrollPane();
        reportersCheckList = new org.japura.gui.CheckList();

        jNumberOfThreadsLabel.setText("Number of threads:");

        jTestListenersLabel.setText("Test Listeners:");

        jAddTestListenerButton.setText("+");

        jRemoveTestListenerButton.setText("-");

        jReportersLabel.setText("Reporters:");

        jAddReporterButton.setText("+");

        jRemoveReporterButton.setText("-");

        testListenersCheckList.setVisibleRowCount(5);
        jScrollPane1.setViewportView(testListenersCheckList);

        reportersCheckList.setVisibleRowCount(5);
        jScrollPane2.setViewportView(reportersCheckList);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jNumberOfThreadsLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jNumberOfThreadsSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))
                            .addComponent(jTestListenersLabel, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jRemoveTestListenerButton, 0, 0, Short.MAX_VALUE)
                                .addComponent(jAddTestListenerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jRemoveReporterButton, 0, 0, Short.MAX_VALUE)
                                .addComponent(jAddReporterButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jReportersLabel)
                        .addContainerGap(244, Short.MAX_VALUE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jNumberOfThreadsLabel)
                    .addComponent(jNumberOfThreadsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTestListenersLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jReportersLabel))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jAddTestListenerButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRemoveTestListenerButton)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jAddReporterButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRemoveReporterButton))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        collapsiblePanel3.add(jPanel2);
//      ------------------------------------------------------------------------


        collapsibleRootPanel1.add(collapsiblePanel1);
        collapsibleRootPanel1.add(collapsiblePanel2);
        collapsibleRootPanel1.add(collapsiblePanel3);
        collapsibleRootPanel1.collapseAll();
        getContentPane().add(collapsibleRootPanel1);
     }

     private void setFormTransparancy(Float opacity) {
        try {
           Class<?> awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
           Method mSetWindowOpacity = awtUtilitiesClass.getMethod("setWindowOpacity", Window.class, float.class);
           mSetWindowOpacity.invoke(null,this, Float.valueOf(opacity));
        } catch (NoSuchMethodException ex) {
           ex.printStackTrace();
        } catch (SecurityException ex) {
           ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
           ex.printStackTrace();
        } catch (IllegalAccessException ex) {
           ex.printStackTrace();
        } catch (IllegalArgumentException ex) {
           ex.printStackTrace();
        } catch (InvocationTargetException ex) {
           ex.printStackTrace();
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton6;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables


    private org.japura.gui.CollapsibleRootPanel collapsibleRootPanel1;
    private org.japura.gui.CollapsiblePanel collapsiblePanel1;
    private org.japura.gui.CollapsiblePanel collapsiblePanel2;
    private org.japura.gui.CollapsiblePanel collapsiblePanel3;
    private javax.swing.JPanel jAuthPanel;

//    private javax.swing.JLabel jCVSUserNameLabel;
//    private javax.swing.JTextField jCVSUserNameField;
//    private javax.swing.JLabel jCVSPasswordLabel;
//    private javax.swing.JPasswordField jCVSPasswordField;


    private javax.swing.JPanel jPanel1;
    private javax.swing.JCheckBox jCVSRemmemberPasswordCheckBox;
    private javax.swing.JLabel jCVSUserNameLabel;
    private javax.swing.JLabel jCVSPasswordLabel;
    private javax.swing.JPasswordField jCVSPasswordField;
    private javax.swing.JTextField jCVSUserNameField;
   
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton jAddReporterButton;
    private javax.swing.JButton jAddTestListenerButton;
    private javax.swing.JLabel jNumberOfThreadsLabel;
    private javax.swing.JSpinner jNumberOfThreadsSpinner;
    private javax.swing.JButton jRemoveReporterButton;
    private javax.swing.JButton jRemoveTestListenerButton;
    private javax.swing.JLabel jReportersLabel;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel jTestListenersLabel;
    private org.japura.gui.CheckList reportersCheckList;
    private org.japura.gui.CheckList testListenersCheckList;
}
